import {get} from '@/common';
export const data = {
    //数据状态
    dataStatus: [
        { value: '00', label: '未确定' },
        { value: '22', label: '已确定' },
        { value: '55', label: '已启用' },
        { value: '77', label: '已禁用' },
        { value: '99', label: '逻辑删除' }
    ],

    dataStatusColorMap: {
        "00": "#303133",
        "22": "#409EFF",
        "55": "#67C23A",
        "77": "#909399",
        "99": "#C0C4CC"
    },

    //产品类型
    prodTypes: [
        { value: 1, label: '白布' },
        { value: 2, label: '色布' },
        { value: 3, label: '无底花布' },
        { value: 4, label: '有底花布' }
    ],

    //质量等级
    prodLevels: [
        { value: '01', label: '一等品' },
        { value: '02', label: '二等品' },
        { value: '03', label: '三等品' },
        { value: '04', label: '等外品' }
    ],

    //流程定义信息（状态信息）
    processStatus: [],
    groupStatus:[],
    productStatus:[],
    storeStatus:[]

    

};

export const getters = {
    text:(state)=>{
        return (mark, code)=>{
            const option = state[mark] && state[mark].find(item => item.value === code);            
		    return option ? option.label : '';
        }
    },  
   
};

export const actions = {
    async init() {
        const result = await get("/public/base/process-def");
        this.processStatus = result.data.map(item => ({ value: item.pd_id, label: item.pd_name }));
        this.groupStatus= result.data.filter(item => item.pd_cls == 1).map(item => ({ value: item.pd_id, label: item.pd_name }));
        this.productStatus = result.data.filter(item => item.pd_cls == 2).map(item => ({ value: item.pd_id, label: item.pd_name }));
        this.storeStatus =  result.data.filter(item => item.pd_cls == 3).map(item => ({ value: item.pd_id, label: item.pd_name }))
    }
};